<template>
  <el-container class="admin-layout">
    <el-aside width="250px" class="sidebar">
      <h1 style="margin-left:20px;color:#fff">医疗器械维修管理系统</h1>
      <el-menu
        :default-active="$route.path"
        class="el-menu-vertical"
        :router="true"
        background-color="#304156"
        text-color="#bfcbd9"
        active-text-color="#409EFF"
      >

        <el-menu-item index="/admin/announcement">
          <el-icon><User /></el-icon>
          <span>账户管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/device">
          <el-icon><Tools /></el-icon>
          <span>器械信息管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/maintenance">
          <el-icon><Document /></el-icon>
          <span>维修工单管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/inventory">
          <el-icon><Box /></el-icon>
          <span>库存管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/purchase">
          <el-icon><ShoppingCart /></el-icon>
          <span>采购管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/statistics">
          <el-icon><TrendCharts /></el-icon>
          <span>数据统计与分析</span>
        </el-menu-item>
   
      </el-menu>
    </el-aside>
    <el-container>
      <el-header height="60px" class="header">
        <div class="header-right">
          <el-dropdown>
            <span class="user-info">
              管理员
            </span>
            <template #dropdown>
              <el-dropdown-menu>
         
                <el-dropdown-item divided @click="handleLogout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()

const handleLogout = () => {
  // 这里可以添加退出登录的逻辑，如清除token等
  router.push('/auth/login')
}
</script>

<style scoped>
.admin-layout {
  height: 100vh;
}

.sidebar {
  background-color: #304156;
  height: 100%;
  overflow-x: hidden;
}

.el-menu-vertical {
  border-right: none;
}

.header {
  background-color: #fff;
  border-bottom: 1px solid #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
}

.header-right {
  display: flex;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.user-info .el-avatar {
  margin-right: 8px;
}
</style>